<? $this->view('head') ?>
<title>销售报表 - 所有房间</title>
<link rel="stylesheet" href="<?= $this->www('css/module/master.css') ?>" type="text/css" media="screen" />
<link rel="stylesheet" href="<?= $this->www('css/module/master/report.css') ?>" type="text/css" />
<script type="text/javascript" src="<?= $this->www('script/module/master.stat.js') ?>"></script>
<script type="text/javascript" src="<?= $this->www('script/plugin/jquery.tablesorter.js') ?>"></script>

<? $this->view('body') ?>
<? $this->view('master/header', array('tab' => 'bbtj')) ?>
<div class="ftt-container">
    <div class="ftt-title clearfix">
        <h2 class="column-left">销售报表 - 所有房间 [ <?= date('Y-m-d', $this->tmln[0]) ?> 至 <?= date('Y-m-d', $this->tmln[1]) ?> ]</h2>
        <input id="print-button" class="column-right button white" type="button" value="打印报表" onclick="window.print();" />
        <input id="force-button" class="column-right button white" type="button" value="导出报表" title="将当前报表导出为CSV格式下载" onclick="location.href=location.pathname+'.csv'+location.search;" />
    </div>
    <div class="reports-query">
        <form action="/master/stat/xsbb-syfj" method="get">
            <label for="reports-period">周期</label>
            <select name="lgth" class="ftt-select" style="width:69px;">
                <? foreach ($this->periods as $key => $val): ?>
                <option value="<?= $key ?>"<?= $key == $this->lgth ? ' selected="selected"' : '' ?>><?= $this->escape($val) ?></option>
                <? endforeach; ?>
            </select>
            <label for="reports-date">日期</label>
            <input type="text" name="date" id="reports-date" class="ftt-input-text short-text input-datepicker" value="<?= $this->date ?>" />
            <input type="submit" class="button white" value="查询" />
        </form>
    </div>
    <div class="reports-wrapper">
        <p class="utime">
            当前列表数据更新时间：<span class="update-T"><?= date('Y-m-d H:i:s', $this->time) ?></span>
        </p>
        <table class="report">
            <thead>
                <tr>
                    <th>房间</th>
                    <th>房型</th>
                    <th>已住销量<br />（间夜）</th>
                    <th>未住销量<br />（间夜）</th>
                    <th>总销量<br />（间夜）</th>
                    <th>成交房费<br />（元）</th>
                    <th>平均房价<br />（元/间夜）</th>
                    <th>入住率</th>
                    <th>占总销量</th>
                    <th>占总房量</th>
                </tr>
            </thead>
            <tbody>
                <? $live_past_sum = $live_fore_sum = $rent_sum = 0 ?>
                <? $time_line_len = ($this->tmln[1]+1 - $this->tmln[0])/86400 ?>
                <? if(empty($this->syfj)): ?>
                <tr>
                    <td colspan="10" class="none">无记录</td>
                </tr>
                <? else: ?>
                <? foreach ($this->syfj as $data): ?>
                <tr>
                    <td><?= $this->escape($data['name']) ?></td>
                    <td><?= $this->escape($data['type']) ?></td>
                    <td><? $live_past_sum+=$data['live']['past'] ?><?= $data['live']['past'] ?></td>
                    <td><? $live_fore_sum+=$data['live']['fore'] ?><?= $data['live']['fore'] ?></td>
                    <td><a target="_blank" title="点击查看来源订单" href="<?= $this->link(array('bdate1' => date('Y-m-d', $this->tmln[1]), 'edate0' => date('Y-m-d', $this->tmln[0]+86400), 'type' => 'room', 'name' => $data['name'], 'state[0]' => ORDER_STATUS_BL, 'state[1]' => ORDER_STATUS_ZZ, 'state[3]' => ORDER_STATUS_YJS), '/master/order/') ?>"><?= $data['live']['past']+$data['live']['fore'] ?></a></td>
                    <td><? $rent_sum+=$data['rent'] ?><?= $data['rent']/100 ?></td>
                    <td><?= ($data['live']['past']+$data['live']['fore']) ? round($data['rent']/($data['live']['past']+$data['live']['fore'])/100, 2) : '0' ?></td>
                    <td><?= round(($data['live']['past']+$data['live']['fore'])/$time_line_len, '4')*100 ?>%</td>
                    <td><?= $this->xszl ? round(($data['live']['past']+$data['live']['fore'])/$this->xszl, '4')*100 : '0' ?>%</td>
                    <td><?= $this->fjzl ? round(($data['live']['past']+$data['live']['fore'])/$this->fjzl, '4')*100 : '0' ?>%</td>
                </tr>
                <? endforeach; ?>
                <? endif; ?>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="2">合计</td>
                    <td><?= $live_past_sum ?></td>
                    <td><?= $live_fore_sum ?></td>
                    <td><a target="_blank" title="点击查看来源订单" href="<?= $this->link(array('bdate1' => date('Y-m-d', $this->tmln[1]), 'edate0' => date('Y-m-d', $this->tmln[0]+86400), 'state[0]' => ORDER_STATUS_BL, 'state[1]' => ORDER_STATUS_ZZ, 'state[3]' => ORDER_STATUS_YJS), '/master/order/') ?>"><?= $live_past_sum + $live_fore_sum ?></a></td>
                    <td><?= $rent_sum/100 ?></td>
                    <td><?= ($live_past_sum+$live_fore_sum) ? round($rent_sum/($live_past_sum+$live_fore_sum)/100, 2) : '0' ?></td>
                    <td>-</td>
                    <td>100%</td>
                    <td><?= $this->fjzl ? round(($live_past_sum+$live_fore_sum)/$this->fjzl, '4')*100 : '0' ?>%</td>
                </tr>
				<tr>
					<td colspan="10" style="text-align:right;color:#686868;">
                        注：本报表不统计预订、已取消订单
					</td>
				</tr>
				<tr>
					<td colspan="10" style="text-align:right;color:#686868;">
                        房间销量 ÷ 总天数 = 入住率<br />各房间销量 ÷ 总销量 = 占总销量<br />各房间销量 ÷ ( 总房数 × 总天数 ) = 占总房量<br />
					</td>
				</tr>
            </tfoot>
        </table>
        <p class="copyright">——由房态通提供的报表</p>
    </div>
</div>

<? $this->view('master/footer') ?>
<script type="text/javascript">$(Z.Module.master.stat.xsbbSyfj.init)</script>
<? $this->view('foot') ?>
